package com.my.springboot.tuling.concurrent;

import java.util.concurrent.CountDownLatch;

public class RunnableDemo implements Runnable {
    private CountDownLatch countDownLatch1;
    private CountDownLatch countDownLatch2;
    private String msg;

    public RunnableDemo(CountDownLatch countDownLatch1, CountDownLatch countDownLatch2, String msg) {
        this.countDownLatch1 = countDownLatch1;
        this.countDownLatch2 = countDownLatch2;
        this.msg = msg;
    }

    @Override
    public void run() {
        try{
            countDownLatch1.await();
            System.out.println(msg);
        }catch (Exception e) {
            e.printStackTrace();
        }
        countDownLatch2.countDown();
    }
}
